package com.hopu.blb_erp.controller;

import com.hopu.blb_erp.entity.ProductionLine;
import com.hopu.blb_erp.service.IProductionLineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author A-Zhang
 * @since 2021-11-24
 */
@Api
@RestController
@Controller
public class ProductionLineController {

    @Autowired
    private IProductionLineService productionLineService;

    @ApiOperation("添加权限")
    @PostMapping("/productionLine")
    public ResponseEntity<String> add(@RequestBody ProductionLine productionLine){
        productionLineService.save(productionLine);
        return ResponseEntity.ok("ok");
    }

    @ApiOperation("更新")
    @PutMapping("/productionLine")
    public ResponseEntity<String> modify(@RequestBody ProductionLine productionLine){
        productionLineService.updateById(productionLine);
        return ResponseEntity.ok("ok");
    }

    @ApiOperation("删除")
    @DeleteMapping("/productionLine/{id}")
    public  ResponseEntity<String> remove(@PathVariable("id") Integer id){
        productionLineService.removeById(id);
        return ResponseEntity.ok("ok");
    }

    @ApiOperation("查询所有")
    @GetMapping("/productionLines")
    public ResponseEntity<List<ProductionLine>> findAll(){
        return ResponseEntity.ok(productionLineService.list());
    }
}
